package com.demo.map;

public class SortedObject implements Comparable<SortedObject> {

    private int age;

    public SortedObject(int age) {
        this.age = age;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public int compareTo(SortedObject sortedObject) {
        return Integer.compare(this.age - sortedObject.getAge(), 0);
    }

    @Override
    public String toString() {
        return "SortedObject{age=" + age + "}";
    }
}
